﻿//https://leetcode.cn/problems/minimum-number-of-arrows-to-burst-balloons/

class Solution {
public:
    int findMinArrowShots(vector<vector<int>>& points)
    {
        //排序
        sort(points.begin(), points.end());

        int n = points.size();
        int ret = 1;
        int right = points[0][1];

        for (int i = 1; i < n; i++)
        {
            int a = points[i][0], b = points[i][1];
            //有重叠部分
            if (a <= right)
            {
                //求交集
                right = min(b, right);
            }
            //无重叠部分
            else
            {
                ret++;
                right = b;
            }
        }

        return ret;
    }
};